package com.nlgc365.designpattern.Chapter04_Pattern.Behavior.P02_Template.Usage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 作用: 钩子函数的写法
 */
public class SomeCaseImpl extends SomeCase {
    private static final Logger logger = LoggerFactory.getLogger(SomeCaseImpl.class);

    /**
     * 写法1: 定义为抽象, 让子类必须继承重写
     * 钩子函数, 作用: 由子类继承, 实现多变需求逻辑
     */
    @Override
    protected void hook() {
        logger.info("The first way to implement hook function.");
    }

    /**
     * 写法2:
     * 与写法1二者选其一
     */
    @Override
    protected void hook2() {
        logger.info("The second way to implement hook function.");
    }
}
